#pragma once
#include <iostream>
#include <stdarg.h>
#include <cstring>
using namespace std;
#define DEBUG 0
#define NORMAL 1
#define WANRING 2
#define ERROR 3
#define FATAL 4
#define NUM 1024
enum
{
    SOCK_ERR = 1,
    BIND_ERR,
    LISTEN_ERR,
    ACCEPT_ERR,
    EPOLL_CREATE_ERR,
    EPOLL_CTL_ERR
};
const char *
getLevel(const int &level)
{
    switch (level)
    {
    case 0:
        return "DEBUG";
    case 1:
        return "NORMAL";
    case 2:
        return "WANRING";
    case 3:
        return "ERROR";
    case 4:
        return "FATAL";
    default:
        return nullptr;
    }
}
void logMessage(int level, const char *format, ...)
{
    va_list arg;
    va_start(arg, format);
    char prefix[NUM];
    snprintf(prefix, sizeof(prefix), "[%s][%d]:", getLevel(level), time(nullptr));
    char message[NUM];
    vsnprintf(message, sizeof(message), format, arg);
    cout << prefix << message << endl;
}
